package com.chen.nio;

import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioTest3 {
    public static void main(String[] args) throws Exception {
        FileOutputStream fis = new FileOutputStream("out.txt");
        FileChannel channel = fis.getChannel();
        String str = "hello,my name is jack";
        ByteBuffer buffer = ByteBuffer.allocate(512);
        buffer.put(str.getBytes());
        buffer.flip();
        channel.write(buffer);
        fis.close();
    }
}
